import request from '@/utils/request'

// 查询计划退料单头列表
export function listPmmMstr(query) {
  return request({
    url: '/putStorage/pmmMstr/list',
    method: 'get',
    params: query
  })
}

// 查询计划退料单头详细
export function getPmmMstr(pmmId) {
  return request({
    url: '/putStorage/pmmMstr/' + pmmId,
    method: 'get'
  })
}

// 新增计划退料单头
export function addPmmMstr(data) {
  return request({
    url: '/putStorage/pmmMstr',
    method: 'post',
    data: data
  })
}

// 新增计划退料单头
export function addPmmMstrChild(data) {
  return request({
    url: '/putStorage/pmmMstr/addChild',
    method: 'post',
    data: data
  })
}

// 修改计划退料单头
export function updatePmmMstr(data) {
  return request({
    url: '/putStorage/pmmMstr',
    method: 'put',
    data: data
  })
}

// 提交单据
export function submitPmmMstr(pmmId) {
  return request({
    url: '/putStorage/pmmMstr/submit/' + pmmId,
    method: 'put'
  })
}

// 单据状态改变
export function updatePmmMstrState(nowztbz, newZtbz, pmmDjbh, remark) {
  return request({
    url: '/putStorage/pmmMstr/check/' + nowztbz + "/" + newZtbz + "/" + pmmDjbh + "/" + remark,
    method: 'put'
  })
}

// 查询可以新增的子项
export function selectPmmMstrAddChild(query) {
  return request({
    url: '/putStorage/pmmMstr/listChild',
    method: 'get',
    params: query
  })
}

// 获取退料明细和统计
export function selectPmmMstrDetailAndTotalByOrder(order) {
  return request({
    url: '/putStorage/pmmMstr/selectPmmDetailAndTotal/' + order,
    method: 'get',
  })
}

// 删除计划退料单头
export function delPmmMstr(pmmId) {
  return request({
    url: '/putStorage/pmmMstr/' + pmmId,
    method: 'delete'
  })
}

// 删除计划退料单头
export function delPmmMstrChild(pmdId) {
  return request({
    url: '/putStorage/pmmMstr/removeChild/' + pmdId,
    method: 'delete'
  })
}

// 导出计划退料单头
export function exportPmmMstr(query) {
  return request({
    url: '/putStorage/pmmMstr/export',
    method: 'get',
    params: query
  })
}
